<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\business\EhrHelper;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $searchModel common\models\MdmTaskSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Mdm Tasks');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mdm-task-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Mdm Task'), ['execute'], ['class' => 'btn btn-primary', 'target'=>'_blank']) ?>
    </p>
    <?php
    try {
        $gv = GridView::widget([
            'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
            'pager'        => [
//            'class'          => GoPager::className(),
                'nextPageLabel'  => '下一页',
                'prevPageLabel'  => '上一页',
                'firstPageLabel' => '首页',
                'lastPageLabel'  => '末页',
                'options'        => [
                    'class' => 'pagination pagination-sm m-t-none m-b-none',
                ],
            ],
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'columns' => [
                [
                    'class'         => 'yii\grid\ActionColumn',
                    'template'      => '{execute} {reset} {sync-to-qywx} {sync-employees-under-department} {sync-employees-photo} {sync-qywx-user} {sync-employee-department-relation} {view} {update} {delete}',
                    'header'        => '操作',
                    'headerOptions' => ['class' => 'text-center no-margin'],
                    'buttons'       => [
                        'execute' => function($url, $model, $key) {
                            $options = [
                                'title' => Yii::t('app', 'Execute'),
                                'data-id' => $key,
                                'target' => '_blank',
                            ];
                            return Html::a('<span class="	glyphicon glyphicon-step-forward edit-class"></span>', $url, $options);
                        },
                        'reset' => function($url, $model, $key) {
                            $options = [
                                'title' => Yii::t('app', 'Reset'),
                                'data-id' => $key,
                            ];
                            return Html::a('<span class="	glyphicon glyphicon-refresh edit-class"></span>', $url, $options);
                        },
                    ],
                ],
                [
                    'class' => 'yii\grid\SerialColumn',
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
                ],
                [
                    'attribute' => 'id',
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
                ],
//                'id',
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'input',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
                    'attribute' => 'flag',
                    'value' => function ($model, $key, $index, $column) {
                        return \backend\helpers\TaskUiHelper::getLabelSpanByMdmTaskFlag($model['flag'], EhrHelper::getMdmTaskFlagStr($model['flag']));
                    },
                    'format'    => 'raw',
                    'filter' => \common\consts\Consts::MDM_TASK_FLAG_MAP(),
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'output',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'started_at',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'stopped_at',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'created_by',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'created_at',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'updated_by',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
                [
//                    'label' => Yii::t('app', 'Layer'),
                    'attribute' => 'updated_at',
                    'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 80px;'],
                    'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'white-space: normal; width: 80px;'],
                ],
            ],
        ]);
    } catch (Exception $e) {
    }
    ?>
    <?= $gv ?>
</div>
